<template>
    <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
        <el-form-item style="width: 60%" label="姓名">
            <el-input v-model="ruleForm.name"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" @click="quary()">查询</el-button>
            <el-button @click="resetForm('ruleForm')">取消</el-button>
            <el-button @click="test()('ruleForm')">Test</el-button>
        </el-form-item>
    </el-form>
</template>
<script>
    export default {
        data() {
            return {
                roleName :'',
                ruleForm: {
                    name: ''
                },
                rules: {
                    name: [
                        { required: true, message: '请输入您的姓名', trigger: 'blur' },
                        { min: 2, max: 5, message: '长度在 2到 5 个字符', trigger: 'blur' }
                    ]
                },
            };
        },



        methods: {
            test(){
                console.log(this.ruleForm)
            },
            quary() {
                this.roleName = this.ruleForm.name;
                const name = this.roleName;
                this.$refs.ruleForm.validate(valid=>{
                    if (!valid)
                        return
                    this.$router.push({
                    path:'/sys/insInformation',
                    query:{
                        name:name,
                    },

                })
                })
            },
            // quary(formName) {
            //     const _this = this
            //     this.$refs[formName].validate((valid) => {
            //         if (valid) {
            //             axios.get('http://localhost:8181/ins/findByName'+_this.$route.query.name).then(function (resp) {
            //                 _this.ruleForm=resp.data
            //                 console.log(_this.ruleForm)
            //             })
            //             _this.$router.push('/InsManage')
            //         } else {
            //             return false;
            //         }
            //     });
            // },
            resetForm(formName) {
                this.$refs[formName].resetFields();
            }
        }
    }
</script>